<template>
  <div>
    <el-breadcrumb separator-icon="ArrowRight" style="margin: 16px">
      <el-breadcrumb-item :to="{ path: '/adminHome' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>房源信息管理</el-breadcrumb-item>
      <el-breadcrumb-item>房源审核</el-breadcrumb-item>
    </el-breadcrumb>
    <el-card style="margin: 15px; min-height: calc(100vh - 111px)">
      <div style="color: black; font-size: 20px;font-weight: bolder; text-align: center;">待审核房源列表</div>
      <div>
        <div style="margin: 40px 0;">
          <div style="margin: 10px 0">
            <el-input v-model="search" 
                      @input="filterData"
                      clearable 
                      placeholder="请输入房东ID号" 
                      prefix-icon="Search"
                      style="width: 20%"/>
            <el-button icon="Search" style="margin-left: 5px" type="primary" @click="filterData"></el-button>
            <el-button icon="refresh-left" style="margin-left: 10px" type="default" @click="reset"></el-button>
          </div>
        </div>
        <!--房源容器-->
        <div v-for="item in tableData" :key="item.houseId">
          <el-card style="width: 100%; margin-bottom: 10px;">
            <div class="common-layout">
              <el-container>
                <!-- 左侧显示图片 -->
                <el-aside width="200px">
                  <el-image :src="item.imageUrl" fit="fill" style="width: 100%; height: 100%"></el-image>
                </el-aside>

                <el-container>
                  <!-- 头部显示标题及链接 -->
                  <el-header style="text-align: center;">
                    <router-link :to="{ name: 'AdminAuditionHouseDisplay', query: { houseId: item.houseId } }">
                      {{ item.title }}
                    </router-link>
                  </el-header>
                  <!-- 房源描述 -->
                  <el-main style="margin-top: -35px;">
                    {{ item.description }}
                  </el-main>
                </el-container>

                <!-- 操作按钮 -->
                <el-aside width="200px" style="display: flex; flex-direction: column; align-items: center; justify-content: center;">
                  <el-space direction="vertical" alignment="center">
                    <el-button icon="CircleCheck" type="primary" @click="handleConfirm(item.houseId)">通过申请</el-button>
                    <el-popconfirm title="确认拒绝该出租请求？" @confirm="handleReject(item.houseId)">
                      <template #reference>
                        <el-button icon="Delete" type="danger">拒绝申请</el-button>
                      </template>
                    </el-popconfirm>
                  </el-space>
                </el-aside>
              </el-container>
            </div>
          </el-card>
        </div>
        <!--分页-->
        <div style="margin: 40px 0">
          <el-pagination
              v-model:currentPage="currentPage"
              :page-size="pageSize"
              :page-sizes="[5, 10, 15]"
              :total="total"
              layout="total, sizes, prev, pager, next, jumper"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"></el-pagination>
        </div>
      </div>
    </el-card>
  </div>
</template>
<script src="@/assets/js/HouseAudition.js"></script>
<style scoped>
.el-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 15px rgba(0, 0, 0, 0.2), 0 6px 20px rgba(0, 0, 0, 0.2);
  border-color: rgba(0, 0, 0, 0.2);
}
</style>